{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ab\n"
     ]
    }
   ],
   "source": [
    "# 多态\n",
    "print('a'+'b')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<function bar at 0x0000020BE26C5488>\n"
     ]
    }
   ],
   "source": [
    "def bar():\n",
    "    a=1\n",
    "    print('a= ',a)\n",
    "def foo(b):\n",
    "    print(b)\n",
    "foo(bar)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<function bar at 0x0000020BE26C5EA0>\n",
      "bar function\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "def bar():\n",
    "    print('bar function')\n",
    "def foo():\n",
    "    return bar\n",
    "ff = foo()\n",
    "print(ff)\n",
    "print(ff())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bar function\n"
     ]
    }
   ],
   "source": [
    "bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bar function\n"
     ]
    }
   ],
   "source": [
    "ff()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this is string example....wow!!!\n"
     ]
    }
   ],
   "source": [
    "\n",
    "st = \"0000000this is string example....wow!!!00\"\n",
    "print(st.strip( '0' ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 默认移除空格strip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this is string 0000 example....wow!!!\n"
     ]
    }
   ],
   "source": [
    "st = \"0000000this is string 0000 example....wow!!!00000\"\n",
    "print(st.strip( '0' ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this is string example....wow!!\n",
      "['this', 'is', 'string', 'example....wow!!']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'is'"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "st = \"     this is string example....wow!!\"\n",
    "print(st.strip())\n",
    "aa=st.strip().split(' ')\n",
    "print(aa)\n",
    "aa[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     this is string example....wow!!\n"
     ]
    }
   ],
   "source": [
    "st = \"     this is string example....wow!!\"\n",
    "print(st.strip('t'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "aa=st.split(' ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['this', 'is', 'string', 'example....wow!!']"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "foo: 2\n",
      "bar: 3\n",
      "None\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "def foo():\n",
    "    x=2\n",
    "    def bar():\n",
    "        x=3\n",
    "        print('bar:',x)\n",
    "    print('foo:',x)\n",
    "    print(bar())\n",
    "print(foo())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
